package com.cykj.controller;

import com.cykj.dto.ResponseDTO;
import com.cykj.feign.OrderFeignClient;
import com.cykj.service.IUserService;
import com.cykj.vo.OrdersVO;
import com.cykj.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Project:JDMS
 * Package:com.cykj.controller
 *
 * @Description:
 * @Author:其一
 * @CreateTime: 2025-07-24-09-56
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;

    @Autowired
    private OrderFeignClient orderFeignClient;

    @PostMapping("/login")
    public ResponseDTO login(@RequestBody UserVO userVO){
        return userService.login(userVO);
    }

    @PostMapping("/register")
    public ResponseDTO register(@RequestBody UserVO userVO){
        return userService.register(userVO);
    }

    @RequestMapping("/selectAll")
    private ResponseDTO selectAllById(UserVO userVO){
        System.out.println(userVO);
        OrdersVO ordersVO = new OrdersVO();
        ordersVO.setOrdersUserId(userVO.getUserId());
        return orderFeignClient.selectAllById(ordersVO);
    }
}
